package cn.zyq.baking.controller;

import cn.zyq.baking.commons.response.JsonResult;
import cn.zyq.baking.service.IBannerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 轮播图查询(为首页进行轮播图数据的加载)
 */
@RestController
@RequestMapping("/banners")
public class BannerController {

    @Autowired
    IBannerService service;

    /**首页显示*/
    @GetMapping("")
    public JsonResult listForIndex(){
        return JsonResult.ok(service.listForIndex());
    }

    @GetMapping("/admin")
    public JsonResult listForAdmin(){
        //List<BannerAdminVO> list = service.listForAdmin();
        //return JsonResult.ok(list);
        return JsonResult.ok(service.listForAdmin());
    }

    @PostMapping("/{id}/delete")
    public JsonResult adminDeleteBannerById(@PathVariable Long id){
        service.deleteById(id);
        return JsonResult.ok();
    }



}
